﻿namespace dotnet_notes.Strategies
{
    /// <summary>
    /// 品牌审核策略工厂
    /// </summary>
    public static class BrandExamineStrategyFactory
    {
        /// <summary>
        /// 审核类型策略字典
        /// </summary>
        private static readonly Dictionary<ExamineTypeEnum?, Func<IExamineStrategy>> dict = new()
        {
            { ExamineTypeEnum.Add, () => new BrandAddStrategy()},
            { ExamineTypeEnum.Modify, () => new BrandModifyStrategy()},
            { ExamineTypeEnum.Delete, () => new BrandDeleteStrategy()},
            { ExamineTypeEnum.Recover, () => new BrandRecoverStrategy()}
        };

        /// <summary>
        /// 获取策略
        /// </summary>
        /// <param name="type">审核类型</param>
        /// <returns></returns>
        public static IExamineStrategy GetStrategy(ExamineTypeEnum? type)
        { 
            if (dict.TryGetValue(type, out var strategy))
            {
                return strategy();
            }

            throw new InvalidOperationException(MessageConfig.InvalidStatus);
        }
    }
}
